﻿//-----------------------------------------------------------------------
// <summary>
//  A module in Prism is a logical unit in your application.
// </summary>
// <copyright file="PropertyModule.cs" company="DSSoftLogic">
//     Copyright@ DSSoftLogic 2011, Non-Commercial. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Property.Silverlight.Module
{
    using System;
    using System.ComponentModel.Composition;
    using Microsoft.Practices.Prism.MefExtensions.Modularity;
    using Microsoft.Practices.Prism.Modularity;
    using Microsoft.Practices.Prism.Regions;
    using Property.Silverlight.Adminstration.Helper;

    /// <summary>
    /// This PropertyModule is testing the StyleCop rules and how to use them.
    /// </summary>
    [ModuleExport(typeof(PropertyModule))]
    public class PropertyModule : IModule
    {
        /// <summary>
        /// Create a private read-only instance variable to hold a reference to the region manager
        /// </summary>
        private readonly IRegionManager regionManager;

        /// <summary>
        /// Create a private read-only instance variable to hold a reference to the container
        /// </summary>
        ////private IUnityContainer container;

        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyModule"/> class.
        /// </summary>
        /// <param name="regionManager">IRegionManager regionManager</param>
        /// <param name="container">IUnityContainer container</param>
        [ImportingConstructor]
        public PropertyModule(IRegionManager regionManager)////, IUnityContainer container)
        {
            ////this.container = container;
            this.regionManager = regionManager;
        }

        /// <summary>
        /// Initialize Method.
        /// In the Initialize method, invoke the RegisterViewWithRegion method on the RegionManager instance. This
        /// method registers a region name with its associated view type in the region view registry; the registry is
        /// responsible for registering and retrieving these mappings.
        /// </summary>
        public void Initialize()
        {
            try
            {
                this.regionManager.RegisterViewWithRegion("ResearchRegion", typeof(View.Views.NewsArticleView));
            }
            catch (Exception ex)
            {
                ErrorExtensioner.FetchError(ex);
            }

            ////this.regionManager.RegisterViewWithRegion(RegionNames.ResearchRegion, () => this.container.Resolve<NewsArticleView>());
            ////this.RegisterViewsAndServices();
            ////if (this.regionManager.Regions.ContainsRegionWithName(Property.Silverlight.Infrastructure.RegionNames.ResearchRegion))
            ////{
            ////    regionManager.Regions[Property.Silverlight.Infrastructure.RegionNames.ResearchRegion].Add(this.container.Resolve<NewsArticleViewModel>().Articles);
            ////}
        }

        /// <summary>
        /// This method is to register Views and Services
        /// </summary>
        ////protected void RegisterViewsAndServices()
        ////{
        ////    this.container.RegisterType<NewsArticleView>();
        ////    ////this.container.RegisterType<IAdvertizementViewModel, PropertyAdvertizementViewModel>();
        ////}
    }
}
